package main

import "fmt"

func uniquePaths(m int, n int) int {
	// 定义一个dp[m][n]数组，dp[i][j]表示到第[i][j]点有多少路径
	// dp[i][j] = dp[i-1][j] + dp[i][j-1]
	// 初始值： dp[i][0] 和 dp[0][j] 都为1

	if m <= 0 || n <= 0 {
		return 0
	}
	dp := make([][]int, m)
	for i := range dp {
		dp[i] = make([]int, n)
		dp[i][0] = 1
		// dp
	}
	for i := range dp[0] {
		dp[0][i] = 1
	}

	for i := 1; i < m; i++ {
		for j := 0; j < n; j++ {
			if j == 0 {
				continue
			}
			dp[i][j] = dp[i-1][j] + dp[i][j-1]
		}
	}
	return dp[m-1][n-1]
}

func main() {
	data := uniquePaths(7, 3)
	fmt.Println(data)
}
